<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="theme-color" content="#222"><meta name="generator" content="Hexo 7.3.0">

  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32.ico">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16.ico">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">



<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" integrity="sha256-wiz7ZSCn/btzhjKDQBms9Hx4sSeUYsDrTLg7roPstac=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.1.1/animate.min.css" integrity="sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancyapps-ui/5.0.28/fancybox/fancybox.css" integrity="sha256-6cQIC71/iBIYXFK+0RHAvwmjwWzkWd+r7v/BX3/vZDc=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/pace/1.2.4/themes/green/pace-theme-minimal.css">
  <script src="https://cdnjs.cloudflare.com/ajax/libs/pace/1.2.4/pace.min.js" integrity="sha256-gqd7YTjg/BtfqWSwsJOvndl0Bxc8gFImLEkXQT8+qj0=" crossorigin="anonymous"></script>

<script class="next-config" data-name="main" type="application/json">{"hostname":"sumumm.github.io","root":"/","images":"/images","scheme":"Gemini","darkmode":false,"version":"8.19.2","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12},"copycode":{"enable":true,"style":"mac"},"fold":{"enable":true,"height":300},"bookmark":{"enable":false,"color":"#222","save":"auto"},"mediumzoom":false,"lazyload":true,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"stickytabs":false,"motion":{"enable":true,"async":true,"transition":{"menu_item":"fadeInDown","post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"i18n":{"placeholder":"搜索...","empty":"没有找到任何搜索结果：${query}","hits_time":"找到 ${hits} 个搜索结果（用时 ${time} 毫秒）","hits":"找到 ${hits} 个搜索结果"},"path":"/search.xml","localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false}}</script><script src="/js/config.js"></script>

    <meta name="description" content="本文主要是STM32开发——使用STM32CubeMX导出Makefile工程，然后通过VSCode来开发的相关笔记，若笔记中有错误或者不合适的地方，欢迎批评指正😃。">
<meta property="og:type" content="article">
<meta property="og:title" content="LV16-07-开发工具-01-STM32CubeMX-Makefile">
<meta property="og:url" content="https://sumumm.github.io/post/daff314e.html">
<meta property="og:site_name" content="苏木">
<meta property="og:description" content="本文主要是STM32开发——使用STM32CubeMX导出Makefile工程，然后通过VSCode来开发的相关笔记，若笔记中有错误或者不合适的地方，欢迎批评指正😃。">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230419232250397.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230419232522160.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230426210514225.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230419233134342.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230426210629918.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230426213033497.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230426213909099.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230426214024128.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230426214228303.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230426214517651.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230426214604370.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230426214838500.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230426215013932.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230426215512905.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230426215744238.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230426224452113.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230426224726235.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230426224838061.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230426225128572.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230426225710937.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230426225626967.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230426225843040.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230426230632688.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230426230122282.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230426230728232.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230426230948750.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230426231029504.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230426231132629.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230426231720359.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230427222754213.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230427223310155.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230427072908842.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230427073034364.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230427073727984.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230427074055930.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230427165944750.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230427170146996.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230427171803285.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230427172022809.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230427172133345.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230427172444867.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230427173928801.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230427171510342.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230427171338781.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230427171510342.png">
<meta property="article:published_time" content="2023-06-04T14:06:34.000Z">
<meta property="article:modified_time" content="2025-06-13T16:25:57.007Z">
<meta property="article:author" content="苏木">
<meta property="article:tag" content="LV16-STM32开发">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230419232250397.png">


<link rel="canonical" href="https://sumumm.github.io/post/daff314e.html">



<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":false,"isPost":true,"lang":"zh-CN","comments":true,"permalink":"https://sumumm.github.io/post/daff314e.html","path":"post/daff314e.html","title":"LV16-07-开发工具-01-STM32CubeMX-Makefile"}</script>

<script class="next-config" data-name="calendar" type="application/json">""</script>
<title>LV16-07-开发工具-01-STM32CubeMX-Makefile | 苏木</title>
  








    <script src="/js/browser_tools_disable.js"></script>

  <noscript>
    <link rel="stylesheet" href="/css/noscript.css">
  </noscript>
<!-- hexo injector head_end start --><link rel="stylesheet" href="https://unpkg.com/hexo-next-tags-plus@latest/lib/tag_plus.css" media="defer" onload="this.media='all'"><!-- hexo injector head_end end --></head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <div class="headband"></div>

  <main class="main">
    <div class="column">
      <header class="header" itemscope itemtype="http://schema.org/WPHeader"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏" role="button">
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <i class="logo-line"></i>
      <p class="site-title">苏木</p>
      <i class="logo-line"></i>
    </a>
      <p class="site-subtitle" itemprop="description">我的学习之路</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger" aria-label="搜索" role="button">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>



<nav class="site-nav">
  <ul class="main-menu menu"><li class="menu-item menu-item-home"><a href="/" rel="section"><i class="fa fa-home fa-fw"></i>苏木的家</a></li><li class="menu-item menu-item-categories"><a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类页<span class="badge">42</span></a></li><li class="menu-item menu-item-archives"><a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档页<span class="badge">673</span></a></li><li class="menu-item menu-item-flink"><a href="/flink/" rel="section"><i class="fa fa-link fa-fw"></i>友人帐</a></li><li class="menu-item menu-item-about"><a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于我</a></li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup"><div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off" maxlength="80"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close" role="button">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div class="search-result-container no-result">
  <div class="search-result-icon">
    <i class="fa fa-spinner fa-pulse fa-5x"></i>
  </div>
</div>

    </div>
  </div>

</header>
        
  
  <aside class="sidebar">

    <div class="sidebar-inner sidebar-nav-active sidebar-toc-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <!--noindex-->
        <div class="post-toc-wrap sidebar-panel">
            <div class="post-toc animated"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%B8%80%E3%80%81STM32CubeMX%E7%94%9F%E6%88%90%E5%B7%A5%E7%A8%8B"><span class="nav-text">一、STM32CubeMX生成工程</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-%E7%94%9F%E6%88%90Makefile"><span class="nav-text">1. 生成Makefile</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-%E4%BF%AE%E6%94%B9Makefile"><span class="nav-text">2. 修改Makefile</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%BA%8C%E3%80%81%E7%BC%96%E8%AF%91%E5%B7%A5%E5%85%B7"><span class="nav-text">二、编译工具</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-%E4%BB%80%E4%B9%88%E6%98%AF%E4%BA%A4%E5%8F%89%E7%BC%96%E8%AF%91"><span class="nav-text">1. 什么是交叉编译</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-%E4%B8%BA%E4%BB%80%E4%B9%88%E4%BC%9A%E6%9C%89%E4%BA%A4%E5%8F%89%E7%BC%96%E8%AF%91"><span class="nav-text">2. 为什么会有交叉编译</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#3-%E4%BA%A4%E5%8F%89%E7%BC%96%E8%AF%91%E9%93%BE"><span class="nav-text">3. 交叉编译链</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#4-%E4%BA%A4%E5%8F%89%E7%BC%96%E8%AF%91%E9%93%BE%E7%9A%84%E5%91%BD%E5%90%8D%E8%A7%84%E5%88%99"><span class="nav-text">4. 交叉编译链的命名规则</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#5-%E6%88%91%E4%BB%AC%E7%9A%84%E5%B7%A5%E7%A8%8B%E7%94%A8%E4%BB%80%E4%B9%88%EF%BC%9F"><span class="nav-text">5. 我们的工程用什么？</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#6-%E4%BA%A4%E5%8F%89%E7%BC%96%E8%AF%91%E5%B7%A5%E5%85%B7%E5%AE%89%E8%A3%85"><span class="nav-text">6. 交叉编译工具安装</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#6-1-%E5%B7%A5%E5%85%B7%E4%B8%8B%E8%BD%BD"><span class="nav-text">6.1 工具下载</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#6-2-%E5%B7%A5%E5%85%B7%E5%AE%89%E8%A3%85"><span class="nav-text">6.2 工具安装</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#6-3-%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F"><span class="nav-text">6.3 环境变量</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#7-make%E5%B7%A5%E5%85%B7%E5%AE%89%E8%A3%85"><span class="nav-text">7. make工具安装</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#7-1-%E5%AE%98%E7%BD%91%E4%B8%8B%E8%BD%BD%E5%AE%89%E8%A3%85-%E6%9A%82%E6%97%B6%E6%94%BE%E5%BC%83"><span class="nav-text">7.1 官网下载安装(暂时放弃)</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#7-2-MinGW"><span class="nav-text">7.2 MinGW</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#7-2-1-%E4%B8%8B%E8%BD%BD"><span class="nav-text">7.2.1 下载</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#7-2-2-%E5%AE%89%E8%A3%85"><span class="nav-text">7.2.2 安装</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#7-2-3-%E6%B7%BB%E5%8A%A0%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F"><span class="nav-text">7.2.3 添加环境变量</span></a></li></ol></li></ol></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%B8%89%E3%80%81%E7%BC%96%E8%AF%91%E5%B7%A5%E7%A8%8B"><span class="nav-text">三、编译工程</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-%E7%BC%96%E8%AF%91"><span class="nav-text">1. 编译</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-%E7%83%A7%E5%86%99"><span class="nav-text">2. 烧写</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#3-%E4%B8%80%E4%B8%AA%E9%94%99%E8%AF%AF"><span class="nav-text">3. 一个错误</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E5%9B%9B%E3%80%81VSCode"><span class="nav-text">四、VSCode</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-VSCode%E6%98%AF%E4%BB%80%E4%B9%88%EF%BC%9F"><span class="nav-text">1. VSCode是什么？</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-Visual-Studio%EF%BC%9F"><span class="nav-text">2. Visual Studio？</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#3-Visual-Studio-%E4%B8%8E-VSCode%E5%B7%AE%E5%BC%82%EF%BC%9F"><span class="nav-text">3. Visual Studio 与 VSCode差异？</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#4-VSCode%E5%AE%89%E8%A3%85"><span class="nav-text">4. VSCode安装</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#1-VSCode%E4%B8%8B%E8%BD%BD"><span class="nav-text">1. VSCode下载</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-VSCode%E5%AE%89%E8%A3%85"><span class="nav-text">2. VSCode安装</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-%E6%8F%92%E4%BB%B6%E5%AE%89%E8%A3%85"><span class="nav-text">3. 插件安装</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#5-%E6%89%93%E5%BC%80%E5%B7%A5%E7%A8%8B%E6%96%87%E4%BB%B6%E5%A4%B9"><span class="nav-text">5. 打开工程文件夹</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#6-%E9%85%8D%E7%BD%AEVSCode"><span class="nav-text">6. 配置VSCode</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#6-1-%E6%8A%A5%E9%94%99%E7%A4%BA%E4%BE%8B"><span class="nav-text">6.1 报错示例</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#6-2-%E5%A4%84%E7%90%86%E6%8A%A5%E9%94%99"><span class="nav-text">6.2 处理报错</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#6-2-1-%E6%96%B9%E5%BC%8F%E4%B8%80%EF%BC%9A%E7%95%8C%E9%9D%A2%E9%85%8D%E7%BD%AE"><span class="nav-text">6.2.1 方式一：界面配置</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#6-2-2-%E6%96%B9%E5%BC%8F%E4%BA%8C%EF%BC%9A%E7%9B%B4%E6%8E%A5%E9%85%8D%E7%BD%AEJSON%E6%96%87%E4%BB%B6"><span class="nav-text">6.2.2 方式二：直接配置JSON文件</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#6-3-%E5%85%B6%E4%BB%96%E9%85%8D%E7%BD%AE"><span class="nav-text">6.3 其他配置</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#6-3-1-compilerPath"><span class="nav-text">6.3.1 compilerPath</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#6-3-2-intelliSenseMode"><span class="nav-text">6.3.2 intelliSenseMode</span></a></li></ol></li></ol></li></ol></li></ol></div>
        </div>
        <!--/noindex-->

        <div class="site-overview-wrap sidebar-panel">
          <div class="site-author animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="苏木"
      src="/images/avatar.jpg">
  <p class="site-author-name" itemprop="name">苏木</p>
  <div class="site-description" itemprop="description">莫道桑榆晚，为霞尚满天</div>
</div>
<div class="site-state-wrap animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
        <a href="/archives/">
          <span class="site-state-item-count">673</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
          <a href="/categories/">
        <span class="site-state-item-count">42</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
        <span class="site-state-item-count">43</span>
        <span class="site-state-item-name">标签</span>
      </div>
  </nav>
</div>
  <div class="links-of-author animated">
      <span class="links-of-author-item">
        <a href="https://github.com/sumumm" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;sumumm" rel="noopener me" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
  </div>

        </div>
      </div>
    </div>

    
  </aside>


    </div>

    <div class="main-inner post posts-expand">


  


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://sumumm.github.io/post/daff314e.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.jpg">
      <meta itemprop="name" content="苏木">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="苏木">
      <meta itemprop="description" content="莫道桑榆晚，为霞尚满天">
    </span>

    <span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
      <meta itemprop="name" content="LV16-07-开发工具-01-STM32CubeMX-Makefile | 苏木">
      <meta itemprop="description" content="">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          LV16-07-开发工具-01-STM32CubeMX-Makefile
        </h1>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2023-06-04 22:06:34" itemprop="dateCreated datePublished" datetime="2023-06-04T22:06:34+08:00">2023-06-04</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/" itemprop="url" rel="index"><span itemprop="name">嵌入式开发</span></a>
        </span>
          ，
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/" itemprop="url" rel="index"><span itemprop="name">01HQ课程体系</span></a>
        </span>
          ，
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/" itemprop="url" rel="index"><span itemprop="name">LV16-STM32开发</span></a>
        </span>
    </span>

  
    <span class="post-meta-break"></span>
    <span class="post-meta-item" title="本文字数">
      <span class="post-meta-item-icon">
        <i class="far fa-file-word"></i>
      </span>
      <span class="post-meta-item-text">本文字数：</span>
      <span>12k</span>
    </span>
    <span class="post-meta-item" title="阅读时长">
      <span class="post-meta-item-icon">
        <i class="far fa-clock"></i>
      </span>
      <span class="post-meta-item-text">阅读时长 &asymp;</span>
      <span>43 分钟</span>
    </span>
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody"><p>本文主要是STM32开发——使用STM32CubeMX导出Makefile工程，然后通过VSCode来开发的相关笔记，若笔记中有错误或者不合适的地方，欢迎批评指正😃。</p>
<span id="more"></span>

<!-- Photo: https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/ -->

<details class="folding-tag" blue><summary> 点击查看使用工具及版本 </summary>
              <div class='content'>
              <table>    <tr>        <td align="center" width=150px>Windows</td>        <td align="left">windows11</td>    </tr>    <tr>        <td align="center">Ubuntu</td>        <td align="left">Ubuntu16.04的64位版本</td>      </tr>    <tr>        <td align="center">VMware® Workstation 16 Pro</td>        <td align="left">16.2.3 build-19376536</td>      </tr>    <tr>        <td align="center">SecureCRT</td>        <td align="left">Version 8.7.2 (x64 build 2214)   -   正式版-2020年5月14日</td>      </tr>    <tr>        <td align="center">开发板</td>        <td align="left">正点原子 i.MX6ULL Linux阿尔法开发板</td>      </tr>    <tr>        <td align="center">uboot</td>        <td align="left">NXP官方提供的uboot，NXP提供的版本为uboot-imx-rel_imx_4.1.15_2.1.0_ga(使用的uboot版本为U-Boot 2016.03)</td>      </tr>    <tr>        <td align="center">linux内核</td>        <td align="left">linux-4.15(NXP官方提供)</td>      </tr>    <tr>        <td align="center">STM32开发板</td>        <td align="left">正点原子战舰V3(STM32F103ZET6)</td>      </tr></table>
              </div>
            </details>

<details class="folding-tag" blue><summary> 点击查看本文参考资料 </summary>
              <div class='content'>
              <ul><li>通用</li></ul><table><tr><td align="center">分类  </td><td align="center">网址</td><td align="center">说明</td></tr><tr><td align="center" rowspan="4">官方网站</td><td align="left"><a href="https://www.arm.com/" target="_blank">https://www.arm.com/</a></td><td align="left">ARM官方网站，在这里我们可以找到Cotex-Mx以及ARMVx的一些文档</td></tr><tr>                                            <td align="left"><a href="https://www.st.com/content/st_com/zh.html" target="_blank">https://www.st.com/content/st_com/zh.html</a></td><td align="left">ST官方网站，在这里我们可以找到STM32的相关文档</td></tr><tr>                                            <td align="left"><a href="https://www.stmcu.com.cn/" target="_blank">https://www.stmcu.com.cn/</a></td><td align="left">意法半导体ST中文官方网站，在这里我们可以找到STM32的相关中文参考文档</td></tr><tr>                                            <td align="left"><a href="http://elm-chan.org/fsw/ff/00index_e.html" target="_blank">http://elm-chan.org/fsw/ff/00index_e.html</a></td><td align="left">FatFs文件系统官网</td></tr><tr><td align="center" rowspan="3">教程书籍</td><td align="left"><a href="STM32开发相关资料/01ARM参考资料/ARM Cortex-M3权威指南(中文).pdf" target="_blank">《ARM Cortex-M3权威指南》</a></td><td alirn="left" rowspan="3">ARM公司专家Joseph Yiu（姚文祥）的力作，中文翻译是NXP的宋岩</td></tr><tr>                                            <td align="left"><a href="STM32开发相关资料/01ARM参考资料/ARM Cortex-M0权威指南(中文).pdf" target="_blank">《ARM Cortex-M0权威指南》</a></td></tr><tr>                                            <td align="left"><a href="" target="_blank">《ARM Cortex-M3与Cortex-M4权威指南》</a></td></tr><tr><td align="center" rowspan="4">开发论坛</td><td align="left"><a href="http://47.111.11.73/forum.php" target="_blank">http://47.111.11.73/forum.php</a></td><td align="left">开源电子网，正点原子的资料下载及问题讨论论坛</td></tr><tr>                                            <td align="left"><a href="https://www.firebbs.cn/forum.php" target="_blank">https://www.firebbs.cn/forum.php</a></td><td align="left">国内Kinetis开发板-野火/秉火（刘火良）主持的论坛，现也做STM32和i.MX RT</td></tr><tr>                                            <td align="left"><a href="https://www.amobbs.com/index.php" target="_blank">https://www.amobbs.com/index.php</a></td><td align="left">阿莫（莫进明）主持的论坛，号称国内最早最火的电子论坛，以交流Atmel AVR系列单片机起家，现已拓展到嵌入式全平台，其STM32系列帖子有70W+。</td></tr><tr>                                            <td align="left"><a href="http://download.100ask.net/index.html" target="_blank">http://download.100ask.net/index.html</a></td><td align="left">韦东山嵌入式资料中心，有些STM32和linux的相关资料也可以来这里找。</td></tr><tr><td align="center" rowspan="3">博客参考</td><td align="left"><a href="http://www.openedv.com/" target="_blank">http://www.openedv.com/</a></td><td align="left">开源网-原子哥个人博客</td></tr><tr>                                            <td align="left"><a href="http://blog.chinaaet.com/jihceng0622" target="_blank">http://blog.chinaaet.com/jihceng0622</a></td><td align="left">博主是原Freescale现NXP的现场应用工程师</td></tr><tr>                                            <td align="left"><a href="https://community.arm.com/arm-community-blogs/b/architectures-and-processors-blog/posts/cortex-m-resources" target="_blank">cortex-m-resources</a></td><td align="left">这其实并不算是一个博客，这是ARM公司专家Joseph Yiu收集整理的所有对开发者有用的官方Cortex-M资料链接（也包含极少数外部资源链接）</td></tr></table><ul><li>STM32</li></ul><table>    <tr><td align="center" rowspan="2">STM32</td><td align="left"><a href="https://doc.embedfire.com/mcu/stm32/f103/hal_general/zh/latest/index.html" target="_blank">STM32 HAL库开发实战指南——基于F103系列开发板</a></td><td align="left">野火STM32开发教程在线文档</td></tr><tr>                                            <td align="left"><a href="https://doc.embedfire.com/mcu/stm32/f103badao/std/zh/latest/index.html" target="_blank">STM32库开发实战指南——基于野火霸道开发板</a></td><td align="left">野火STM32开发教程在线文档</td></tr></table><ul><li>SD卡</li></ul><table>    <tr><td align="left"><a href="https://www.sdcard.org/" target="_blank">SD Association</a></td><td align="left">提供了SD存储卡和SDIO卡系统规范</td></tr></table>
              </div>
            </details>

<details class="folding-tag" blue><summary> 点击查看相关文件下载 </summary>
              <div class='content'>
              <table>    <tr><td align="left"><a href="https://www.st.com/resource/en/datasheet/stm32f103ze.pdf" target="_blank">STM32F103xx英文数据手册</a></td><td align="left">STM32F103xC/D/E系列的英文数据手册</td></tr>    <tr><td align="left"><a href="https://www.stmcu.com.cn/Designresource/detail/localization_document%20/709978" target="_blank">STM32F103xx中文数据手册</a></td><td align="left">STM32F103xC/D/E系列的中文数据手册</td></tr>    <tr><td align="left"><a href="https://www.st.com/resource/en/reference_manual/rm0008-stm32f101xx-stm32f102xx-stm32f103xx-stm32f105xx-and-stm32f107xx-advanced-armbased-32bit-mcus-stmicroelectronics.pdf" target="_blank">STM32F10xxx英文参考手册（RM0008）</a></td><td align="left">STM32F10xxx系列的英文参考手册</td></tr>    <tr><td align="left"><a href="https://www.stmcu.com.cn/Designresource/detail/localization_document%20/710001" target="_blank">STM32F10xxx中文参考手册（RM0008）</a></td><td align="left">STM32F10xxx系列的中文参考手册</td></tr>    <tr><td align="left"><a href="https://developer.arm.com/documentation/100165/0201/?lang=en" target="_blank">Arm Cortex-M3 处理器技术参考手册-英文版</a></td><td align="left">Cortex-M3技术参考手册-英文版</td></tr>    <tr><td align="left"><a href="https://www.st.com/resource/en/programming_manual/pm0056-stm32f10xxx20xxx21xxxl1xxxx-cortexm3-programming-manual-stmicroelectronics.pdf" target="_blank">STM32F10xxx Cortex-M3编程手册-英文版(PM0056)</a></td><td align="left">STM32F10xxx/20xxx/21xxx/L1xxxx系列Cortex-M3编程手册-英文版</td></tr>    <tr><td align="left"><a href="https://www.sdcard.org/downloads/pls/" target="_blank">SD卡相关资料——最新版本</a></td><td align="left">有关SD卡的一些资料可以从这里下载</td></tr>    <tr><td align="left"><a href="https://www.sdcard.org/downloads/pls/archives/" target="_blank">SD卡相关资料——历史版本</a></td><td align="left">有关SD卡的一些历史版本资料可以从这里下载，比如后边看的SD卡2.0协议</td></tr>    <tr><td align="left"><a href="./" target="_blank">SD 2.0 协议标准完整版</a></td><td align="left">这是一篇关于SD卡2.0协议的中文文档，还是比较有参考价值的，可以一看</td></tr></table>
              </div>
            </details> 

<h1 id="一、STM32CubeMX生成工程"><a href="#一、STM32CubeMX生成工程" class="headerlink" title="一、STM32CubeMX生成工程"></a><font size=3>一、STM32CubeMX生成工程</font></h1><h2 id="1-生成Makefile"><a href="#1-生成Makefile" class="headerlink" title="1. 生成Makefile"></a><font size=3>1. 生成Makefile</font></h2><p>前边我们已经熟悉了一下STM32CubeMX软件的使用方法，以及创建和导出MDK工程的过程，接下来我们创建一个含有Makefile文件的工程。</p>
<ul>
<li>（1）【File】&rarr;【New Project】</li>
</ul>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230419232250397.png" alt="image-20230419232250397" style="zoom:25%;" />

<ul>
<li>（2）【选择芯片型号】&rarr;【Start Project】</li>
</ul>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230419232522160.png" alt="image-20230419232522160" style="zoom: 20%;" />

<ul>
<li>（3）【Project Manager】&rarr;【Project】</li>
</ul>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230426210514225.png" alt="image-20230426210514225" style="zoom: 25%;" />

<ul>
<li>（4）【Project Manager】&rarr;【Code Generator】</li>
</ul>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230419233134342.png" alt="image-20230419233134342" style="zoom:25%;" />

<ul>
<li>（5）点击右上角的全大写的【GENERATE CODE】然后等待生成工程即可，生成的工程文件如下图所示：</li>
</ul>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230426210629918.png" alt="image-20230426210629918" style="zoom: 50%;" />

<h2 id="2-修改Makefile"><a href="#2-修改Makefile" class="headerlink" title="2. 修改Makefile"></a><font size=3>2. 修改Makefile</font></h2><p>工程导出的Makefile文件只包含工程自动生成的文件及目录位置，我们要是有自定义的源文件和头文件怎么办？</p>
<ul>
<li>源文件添加位置</li>
</ul>
<figure class="highlight makefile"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">######################################</span></span><br><span class="line"><span class="comment"># source</span></span><br><span class="line"><span class="comment">######################################</span></span><br><span class="line"><span class="comment"># C sources</span></span><br><span class="line">C_SOURCES =  \</span><br></pre></td></tr></table></figure>

<p>在这个最后边追加就可以了，当我们在STM32CubeMX中增加或者删除功能的时候不会影响到我们自己添加的这些。</p>
<ul>
<li>头文件添加位置</li>
</ul>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"># C includes</span><br><span class="line">C_INCLUDES =  \</span><br></pre></td></tr></table></figure>

<p>我们加到这个后边就可以了。我们只需要修改这两个地方即可，其他的保持默认。我尝试了一下，我们添加在这两个变量后边的内容不受STM32CubeMX软件的影响，不管是在哪个位置，可以放心添加。</p>
<h1 id="二、编译工具"><a href="#二、编译工具" class="headerlink" title="二、编译工具"></a><font size=3>二、编译工具</font></h1><p>我们可以参考下这篇文档：<a target="_blank" rel="noopener" href="http://landley.net/writing/docs/cross-compiling.html">Introduction to cross-compiling for Linux (landley.net)</a></p>
<h2 id="1-什么是交叉编译"><a href="#1-什么是交叉编译" class="headerlink" title="1. 什么是交叉编译"></a><font size=3>1. 什么是交叉编译</font></h2><ul>
<li>本地编译</li>
</ul>
<p>本地编译可以理解为，在当前编译平台下，编译出来的程序只能放到当前平台下运行。平时我们常见的软件开发，都是属于本地编译。比如，我们在 x86 平台上，编写程序并编译成可执行程序。这种方式下，我们使用 x86 平台上的工具，开发针对 x86 平台本身的可执行程序，这个编译过程称为本地编译。</p>
<ul>
<li>交叉编译</li>
</ul>
<p>交叉编译可以理解为，在当前编译平台下，编译出来的程序能运行在体系结构不同的另一种目标平台上，但是编译平台本身却不能运行该程序。比如，我们在 x86 平台上，编写程序并编译成能运行在 ARM 平台的程序，编译得到的程序在 x86 平台上是不能运行的，必须放到 ARM 平台上才能运行。</p>
<h2 id="2-为什么会有交叉编译"><a href="#2-为什么会有交叉编译" class="headerlink" title="2. 为什么会有交叉编译"></a><font size=3>2. 为什么会有交叉编译</font></h2><p>主要原因有以下几点：</p>
<p>（1）Speed： 目标平台的运行速度往往比主机慢得多，许多专用的嵌入式硬件被设计为低成本和低功耗，没有太高的性能.</p>
<p>（2）Capability： 整个编译过程是非常消耗资源的，嵌入式系统往往没有足够的内存或磁盘空间。</p>
<p>（3）Availability： 即使目标平台资源很充足，可以本地编译，但是第一个在目标平台上运行的本地编译器总需要通过交叉编译获得。</p>
<p>（4）Flexibility： 一个完整的Linux编译环境需要很多支持包，交叉编译使我们不需要花时间将各种支持包移植到目标板上。</p>
<h2 id="3-交叉编译链"><a href="#3-交叉编译链" class="headerlink" title="3. 交叉编译链"></a><font size=3>3. 交叉编译链</font></h2><p>我们来看看什么是交叉编译链。首先编译过程是按照不同的子功能，依照先后顺序组成的一个复杂的流程，如下图：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230426213033497.png" alt="image-20230426213033497" style="zoom: 33%;" />

<p>编译过程包括了预处理、编译、汇编、链接等功能。每个过程都是一个单独的工具来实现，它们合在一起形成了一个完整的工具集。</p>
<p>同时编译过程又是一个有先后顺序的流程，它必然牵涉到工具的使用顺序，每个工具按照先后关系串联在一起，这就形成了一个链式结构。</p>
<p>因此，交叉编译链就是为了编译跨平台体系结构的程序代码而形成的由多个子工具构成的一套完整的工具集。同时，它隐藏了预处理、编译、汇编、链接等细节，当我们指定了源文件(.c)时，它会自动按照编译流程调用不同的子工具，自动生成最终的二进制程序映像(.bin)。</p>
<p>注意：严格意义上来说，交叉编译器，只是指交叉编译的gcc，但是实际上为了方便，我们常说的交叉编译器就是交叉工具链。本文对这两个概念不加以区分，都是指编译链。</p>
<h2 id="4-交叉编译链的命名规则"><a href="#4-交叉编译链的命名规则" class="headerlink" title="4. 交叉编译链的命名规则"></a><font size=3>4. 交叉编译链的命名规则</font></h2><p>我们使用交叉编译链时，常常会看到这样的名字：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">arm-none-linux-gnueabi-gcc</span><br><span class="line">arm-cortex_a8-linux-gnueabi-gcc</span><br><span class="line">mips-malta-linux-gnu-gcc</span><br></pre></td></tr></table></figure>


<p>其中，对应的前缀为：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">arm-none-linux-gnueabi-</span><br><span class="line">arm-cortex_a8-linux-gnueabi-</span><br><span class="line">mips-malta-linux-gnu-</span><br></pre></td></tr></table></figure>

<p>这些交叉编译链的命名规则似乎是通用的，有一定的规则：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">arch-core-kernel-system</span><br><span class="line">arch： 用于哪个目标平台。</span><br><span class="line">core： 使用的是哪个CPU Core，如Cortex A8，但是这一组命名好像比较灵活，在其它厂家提供的交叉编译链中，有以厂家名称命名的，也有以开发板命名的，或者直接是none或cross的。</span><br><span class="line">kernel： 所运行的OS，见过的有Linux，uclinux，bare（无OS）。</span><br><span class="line">system：交叉编译链所选择的库函数和目标映像的规范，如gnu，gnueabi等。其中gnu等价于glibc+oabi；gnueabi等价于glibc+eabi。</span><br></pre></td></tr></table></figure>

<p>注意：这个规则是一个总结的规律罢了，并没有在哪份官方资料上看到过，而且有些编译链的命名确实没有按照这个规则。</p>
<h2 id="5-我们的工程用什么？"><a href="#5-我们的工程用什么？" class="headerlink" title="5. 我们的工程用什么？"></a><font size=3>5. 我们的工程用什么？</font></h2><p>那我们的工程用哪个交叉编译工具链呢？我们来看一下Makefile文件：</p>
<figure class="highlight makefile"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#######################################</span></span><br><span class="line"><span class="comment"># binaries</span></span><br><span class="line"><span class="comment">#######################################</span></span><br><span class="line">PREFIX = arm-none-eabi-</span><br><span class="line"><span class="comment"># The gcc compiler bin path can be either defined in make command via GCC_PATH variable (&gt; make GCC_PATH=xxx)</span></span><br><span class="line"><span class="comment"># either it can be added to the PATH environment variable.</span></span><br><span class="line"><span class="keyword">ifdef</span> GCC_PATH</span><br><span class="line">CC = <span class="variable">$(GCC_PATH)</span>/<span class="variable">$(PREFIX)</span>gcc</span><br><span class="line">AS = <span class="variable">$(GCC_PATH)</span>/<span class="variable">$(PREFIX)</span>gcc -x assembler-with-cpp</span><br><span class="line">CP = <span class="variable">$(GCC_PATH)</span>/<span class="variable">$(PREFIX)</span>objcopy</span><br><span class="line">SZ = <span class="variable">$(GCC_PATH)</span>/<span class="variable">$(PREFIX)</span>size</span><br><span class="line"><span class="keyword">else</span></span><br><span class="line">CC = <span class="variable">$(PREFIX)</span>gcc</span><br><span class="line">AS = <span class="variable">$(PREFIX)</span>gcc -x assembler-with-cpp</span><br><span class="line">CP = <span class="variable">$(PREFIX)</span>objcopy</span><br><span class="line">SZ = <span class="variable">$(PREFIX)</span>size</span><br><span class="line"><span class="keyword">endif</span></span><br></pre></td></tr></table></figure>

<p>我们可以看到有上边这一段，这里就指明了默认使用的交叉编译工具链的名称：arm-none-eabi-</p>
<h2 id="6-交叉编译工具安装"><a href="#6-交叉编译工具安装" class="headerlink" title="6. 交叉编译工具安装"></a><font size=3>6. 交叉编译工具安装</font></h2><h3 id="6-1-工具下载"><a href="#6-1-工具下载" class="headerlink" title="6.1 工具下载"></a><font size=3>6.1 工具下载</font></h3><p>我们直接百度搜索一下，就会看到这个编译工具链的官网，其实我们再ARM的官网也可以找得到：[Arm GNU Toolchain](<a target="_blank" rel="noopener" href="https://developer.arm.com/Tools">https://developer.arm.com/Tools</a> and Software&#x2F;GNU Toolchain)</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230426213909099.png" alt="image-20230426213909099" style="zoom: 25%;" />

<p>我们来到下载页面：<a target="_blank" rel="noopener" href="https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads">Arm GNU Toolchain Downloads – Arm Developer</a></p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230426214024128.png" alt="image-20230426214024128" style="zoom:33%;" />

<p>我们选这个把，因为看上去，只需要双击就可以啦。我们好像也可以在这里下载：<a target="_blank" rel="noopener" href="https://launchpad.net/gcc-arm-embedded/+download">GNU Arm Embedded Toolchain project files : GNU Arm Embedded Toolchain (launchpad.net)</a></p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230426214228303.png" alt="image-20230426214228303" style="zoom:33%;" />

<p>感觉差不多，我是在ARM官网那个链接里边下载的。</p>
<h3 id="6-2-工具安装"><a href="#6-2-工具安装" class="headerlink" title="6.2 工具安装"></a><font size=3>6.2 工具安装</font></h3><p>我们下载完毕后，会得到这样一个可执行文件：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230426214517651.png" alt="image-20230426214517651" style="zoom:50%;" />

<p>我们双击进行安装，一路默认就是了，这一步注意一下，就是安装路径，后边我们还要添加环境变量，这里的路径可以记一下安装在哪。</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230426214604370.png" alt="image-20230426214604370" style="zoom:33%;" />

<p>我是按照默认的路径安装的：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">C:\Program Files (x86)\Arm GNU Toolchain arm-none-eabi\12.2 mpacbti-rel1</span><br></pre></td></tr></table></figure>

<p>最后等待安装完成就是了，安装完成后，我们会看到这样一个界面：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230426214838500.png" alt="image-20230426214838500" style="zoom:33%;" />

<p>注意这里有把软件加进环境变量的选项，我们可以勾选上，这样后边就不用手动添加了。安装完毕后，我们来到安装目录，看一下我们安装的工具都有哪些：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230426215013932.png" alt="image-20230426215013932" style="zoom:33%;" />

<p>这便是我们安装的工具啦。</p>
<h3 id="6-3-环境变量"><a href="#6-3-环境变量" class="headerlink" title="6.3 环境变量"></a><font size=3>6.3 环境变量</font></h3><p>安装完毕后，我们在命令行是无法直接使用命令的，我们还要将命令的路径告诉系统，这个时候就需要添加环境变量啦。当然，前边安装的时候勾选了添加环境变量的话，这里应该就不用手动添加了：</p>
<ul>
<li>（1）找到此电脑图标，【右键】&rarr;【属性】&rarr;【高级系统设置】</li>
</ul>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230426215512905.png" alt="image-20230426215512905" style="zoom:33%;" />

<ul>
<li>（2）【环境变量】&rarr;【用户环境变量】&rarr;【PATH】&rarr;【新建】</li>
</ul>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230426215744238.png" alt="image-20230426215744238" style="zoom: 25%;" />

<p>我们新建一个环境变量，填入刚才的路径：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">C:\Program Files (x86)\Arm GNU Toolchain arm-none-eabi\12.2 mpacbti-rel1\bin</span><br></pre></td></tr></table></figure>

<p>然后依次选择确认或者OK即可。</p>
<ul>
<li>（3）是否设置成功？</li>
</ul>
<p>我们随便找一个目录，然后【右键】&rarr;【在终端打开（win11才有）】，若是没有在终端打开的选项，我们也可以win+r调出运行窗口，然后输入cmd后按回车，打开命令行也行，打开后我们输入以下命令：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">PS C:\Users\20380&gt; arm-none-eabi-gcc -v</span><br></pre></td></tr></table></figure>

<p>若有以下打印信息，则说明安装和添加环境变量成功：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">PS C:\Users\20380&gt; arm-none-eabi-gcc -v</span><br><span class="line">Using built-in specs.</span><br><span class="line">COLLECT_GCC=C:\Program Files (x86)\Arm GNU Toolchain arm-none-eabi\12.2 mpacbti-rel1\bin\arm-none-eabi-gcc.exe</span><br><span class="line">COLLECT_LTO_WRAPPER=c:/program\ files\ (x86)/arm\ gnu\ toolchain\ arm-none-eabi/12.2\ mpacbti-rel1/bin/../libexec/gcc/arm-none-eabi/12.2.1/lto-wrapper.exe</span><br><span class="line">Target: arm-none-eabi</span><br><span class="line">Configured with: /data/jenkins/workspace/GNU-toolchain/arm-12-mpacbti/src/gcc/configure --target=arm-none-eabi --prefix=/data/jenkins/workspace/GNU-toolchain/arm-12-mpacbti/build-mingw-arm-none-eabi/install --with-gmp=/data/jenkins/workspace/GNU-toolchain/arm-12-mpacbti/build-mingw-arm-none-eabi/host-tools --with-mpfr=/data/jenkins/workspace/GNU-toolchain/arm-12-mpacbti/build-mingw-arm-none-eabi/host-tools --with-mpc=/data/jenkins/workspace/GNU-toolchain/arm-12-mpacbti/build-mingw-arm-none-eabi/host-tools --with-isl=/data/jenkins/workspace/GNU-toolchain/arm-12-mpacbti/build-mingw-arm-none-eabi/host-tools --disable-shared --disable-nls --disable-threads --disable-tls --enable-checking=release --enable-languages=c,c++,fortran --with-newlib --with-gnu-as --with-gnu-ld --with-sysroot=/data/jenkins/workspace/GNU-toolchain/arm-12-mpacbti/build-mingw-arm-none-eabi/install/arm-none-eabi --with-multilib-list=aprofile,rmprofile --with-libiconv-prefix=/data/jenkins/workspace/GNU-toolchain/arm-12-mpacbti/build-mingw-arm-none-eabi/host-tools --host=i686-w64-mingw32 --with-pkgversion=&#x27;Arm GNU Toolchain 12.2.MPACBTI-Rel1 (Build arm-12-mpacbti.34)&#x27; --with-bugurl=https://bugs.linaro.org/</span><br><span class="line">Thread model: single</span><br><span class="line">Supported LTO compression algorithms: zlib</span><br><span class="line">gcc version 12.2.1 20230214 (Arm GNU Toolchain 12.2.MPACBTI-Rel1 (Build arm-12-mpacbti.34))</span><br></pre></td></tr></table></figure>

<p>【注意】若是没有任何信息，可能是环境变量未生效，我们可以重启电脑再试。</p>
<h2 id="7-make工具安装"><a href="#7-make工具安装" class="headerlink" title="7. make工具安装"></a><font size=3>7. make工具安装</font></h2><p>我们在linux下基本都会安装make工具，但是windows下不一样，我们大概率是没有安装的。</p>
<h3 id="7-1-官网下载安装-暂时放弃"><a href="#7-1-官网下载安装-暂时放弃" class="headerlink" title="7.1 官网下载安装(暂时放弃)"></a><font size=3>7.1 官网下载安装(暂时放弃)</font></h3><p>这个比较坑，我尝试了从GNU官网安装make，结果在生成的时候报下边的错，我也看不懂，感觉挺复杂，就放弃啦，转而使用另一种方式。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">PS D:\BaiduNetdiskDownload\make-4.4\make-4.4&gt; .\build_w32.bat</span><br><span class="line"></span><br><span class="line">Creating GNU Make for Windows 9X/NT/2K/XP/Vista/7/8/10</span><br><span class="line"></span><br><span class="line">No MSVC compiler available.</span><br><span class="line">Please run vcvarsall.bat and/or configure your Path.</span><br></pre></td></tr></table></figure>

<p>这里还是记一下官网的位置吧，万一以后知道怎么解决了呢。</p>
<ul>
<li>GNU官网：<a target="_blank" rel="noopener" href="https://www.gnu.org/software/software.html">软件 - GNU 工程 - 自由软件基金会</a></li>
<li>Make：<a target="_blank" rel="noopener" href="https://www.gnu.org/software/make/">Make - GNU Project - Free Software Foundation</a></li>
</ul>
<h3 id="7-2-MinGW"><a href="#7-2-MinGW" class="headerlink" title="7.2 MinGW"></a><font size=3>7.2 MinGW</font></h3><p>MinGW是一个GNU编译器集合(GCC)的本机Windows端口，具有可自由分发的导入库和头文件，用于构建本机Windows应用程序;包括对MSVC运行时的扩展，以支持C99功能。MinGW的所有软件都将在64位Windows平台上运行，安装后，默认会有make工具，所以win下使用make的话，就通过这种方式喽。</p>
<h4 id="7-2-1-下载"><a href="#7-2-1-下载" class="headerlink" title="7.2.1 下载"></a><font size=3>7.2.1 下载</font></h4><p>网上发现MinGW里边含有make，所以我们只要转而用这个里边的make啦。我们可以在这里下载MinGW：<a target="_blank" rel="noopener" href="https://sourceforge.net/projects/mingw/files/Installer/">MinGW - Minimalist GNU for Windows - Browse &#x2F;Installer at SourceForge.net</a>，另外还有一个地址，这里也能找到下载的地方：<a target="_blank" rel="noopener" href="https://sourceforge.net/projects/mingw/files/MinGW/">MinGW - Minimalist GNU for Windows - Browse &#x2F;MinGW at SourceForge.net</a></p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230426224452113.png" alt="image-20230426224452113" style="zoom: 33%;" />

<h4 id="7-2-2-安装"><a href="#7-2-2-安装" class="headerlink" title="7.2.2 安装"></a><font size=3>7.2.2 安装</font></h4><p>下载完成后我们会得到这样一个可执行文件：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230426224726235.png" alt="image-20230426224726235" style="zoom:50%;" />

<p>我们双击运行，后边一路下一步就是了，这里可以注意记一下安装目录，我是安装在默认的目录下</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">C:\MinGW</span><br></pre></td></tr></table></figure>

<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230426224838061.png" alt="image-20230426224838061" style="zoom:33%;" />

<p>然后安装完毕后就会进入一个包的安装管理界面：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230426225128572.png" alt="image-20230426225128572" style="zoom: 25%;" />

<p>这里会打开MinGW Installer（后续我们也可以打开这个软件来管理我们的工具包）让我们选择要安装的包，我一般就选择的第二个（mingw32-base），然后左上角选择【Installation】&rarr;【Apply Changes】</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230426225710937.png" alt="image-20230426225710937" style="zoom:33%;" />

<p>后边会开始安装我们选择的包，安装完毕后如下图，点击close即可：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230426225626967.png" alt="image-20230426225626967" style="zoom: 50%;" />

<p>然后我们就可以在安装目录下找到一个make工具啦：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230426225843040.png" alt="image-20230426225843040" style="zoom:33%;" />

<p>但是它的名字并不是make，为了后边方便使用，我们可以复制一个可执行文件，并命名为make.exe</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230426230632688.png" alt="image-20230426230632688" style="zoom:50%;" />

<h4 id="7-2-3-添加环境变量"><a href="#7-2-3-添加环境变量" class="headerlink" title="7.2.3 添加环境变量"></a><font size=3>7.2.3 添加环境变量</font></h4><p>步骤与上边添加交叉编译工具的环境变量的步骤一样，这里就不写了，环境变量的路径为：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">C:\MinGW\bin</span><br></pre></td></tr></table></figure>

<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230426230122282.png" alt="image-20230426230122282" style="zoom:50%;" />

<p>然后我们随便找一个位置打开终端，输入以下命令：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">make -v</span><br></pre></td></tr></table></figure>

<p>若有以下输出，则说明我们安装成功啦，并且环境变量已生效。</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230426230728232.png" alt="image-20230426230728232" style="zoom:50%;" />

<h1 id="三、编译工程"><a href="#三、编译工程" class="headerlink" title="三、编译工程"></a><font size=3>三、编译工程</font></h1><h2 id="1-编译"><a href="#1-编译" class="headerlink" title="1. 编译"></a><font size=3>1. 编译</font></h2><p>我们已经安装好make和交叉编译工具链了，接下来就是编译工程和验证啦。我们进入工程目录，然后右键打开终端，并执行make命令：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230426230948750.png" alt="image-20230426230948750" style="zoom:50%;" />

<p>随后便开始编译整个工程，编译完成后如下图所示：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230426231029504.png" alt="image-20230426231029504" style="zoom:50%;" />

<p>我们来看一下这个build文件夹，发现生成了一系列的文件，有没有很眼熟呢？</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230426231132629.png" alt="image-20230426231132629" style="zoom:50%;" />

<p>哈哈，这个hex文件我们可以烧到STM32里边看一下能不能跑。</p>
<h2 id="2-烧写"><a href="#2-烧写" class="headerlink" title="2. 烧写"></a><font size=3>2. 烧写</font></h2><p>这里就不写过程了，我们直接用J-Link的J-Flash工具烧写生成的hex文件就好啦：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230426231720359.png" alt="image-20230426231720359" style="zoom:33%;" />

<p>我这里是更换了一个LED的例子，不然烧写进去也没什么效果，经过验证，程序可以正常跑。</p>
<h2 id="3-一个错误"><a href="#3-一个错误" class="headerlink" title="3. 一个错误"></a><font size=3>3. 一个错误</font></h2><p>们想要清理中间文件呢？我们可以执行下边的命令：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">make clean</span><br></pre></td></tr></table></figure>

<p>但是吧用本地的终端似乎会有问题，会有如下报错：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230427222754213.png" alt="image-20230427222754213" style="zoom:50%;" />

<p>这个命令按理说是要删除掉由make执行后生成的build目录的，但是看上边就报错了，似乎是执行失败了，也许是这个终端终究linux不太一样把，由于我装了git版本控制工具，它自带一个终端，这个git bash终端就可以正常执行上边的命令并清理相应的文件：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230427223310155.png" alt="image-20230427223310155" style="zoom:50%;" />

<p>我们后边可以使用这个终端，以及后边使用vscode来作为编辑器编辑工程的时候使用的终端也是这一个。</p>
<h1 id="四、VSCode"><a href="#四、VSCode" class="headerlink" title="四、VSCode"></a><font size=3>四、VSCode</font></h1><h2 id="1-VSCode是什么？"><a href="#1-VSCode是什么？" class="headerlink" title="1. VSCode是什么？"></a><font size=3>1. VSCode是什么？</font></h2><p>VS Code的全称是Visual Studio Code，但这全名实在是太长了，很多用户喜欢叫它 VS Code。说起VS Code，官方定义它是一个免费的、开源的跨平台<strong>编辑器</strong>。之所以强调“编辑器”，应该是是因为 VS Code 并无意成为一个全尺寸的集成开发环境，也就是IDE。它是Microsoft在2015年4月30日Build开发者大会上正式宣布一个运行于Mac OS X、Windows和Linux之上的，针对于编写现代Web和云应用的跨平台源代码编辑器，可在桌面上运行，并且可用于Windows，macOS和Linux。</p>
<p>编辑器并等同于IDE。IDE 更为关注开箱即用的编程体验、对代码往往有很好的智能理解，同时侧重于工程项目，为代码调试、测试、工作流等都有图形化界面的支持，因此相对笨重，Java程序员常用的Eclipse定位就是IDE；而编辑器则相对更轻量，侧重于文件或者文件夹，语言和工作流的支持更丰富和自由，VS Code 把自己定位在编辑器这个方向上，但又不完全局限于此。</p>
<p>2011 年底，微软从 IBM 请来了 Erich Gamma。Erich Gamma 是《设计模式》一书的作者之一，曾和肯特·贝克（Kent Beck） 一起发明了 JUnit，并且在 IBM 领导 Java 开发工具的开发工作。微软把他请过来，就是希望他能够打造一款在线的开发工具，让开发者们能够在浏览器里获得 IDE 般的开发体验，这也就是之后为人所知的 Monaco Editor。</p>
<p>Erich Gamma 见证了 Eclipse 从崛起到逐渐臃肿，再逐渐式微的整个历程，他深刻认识到 Eclipse 成功的一部分原因是极度的可定制化特性，任何功能在Eclipse中都可以用插件来实现；但是由于 Eclipse 的插件跟核心代码运行在同一个进程内，随着插件的增多，核心功能经常会被插件拖累，也就更加让人觉得笨重。因此，在打造 Monaco Editor 时，开发团队非常注重核心功能的性能，尽可能地保持轻量，而对资源和性能消耗较大的功能，则运行在其他的进程之中。</p>
<p>2015 年，Erich Gamma 带领团队把 Monaco Editor 移植到桌面平台上，也就是这个专栏的主角 Visual Studio Code，即 VS Code。VS Code 继承了 Monaco Editor 的设计原则，其核心是做一个高性能的轻量级编辑器；个性化的功能，则交给插件系统来完成。这一点可以说是师承 Eclipse，但同时又吸取了 Eclipse 的教训，把插件系统运行在主进程之外，高度可定制但同时又是可控的。与此同时，VS Code 也有自己的使命，那就是让开发者在编辑器里拥有 IDE 那样的开发体验，比如对源代码有智能的理解、图形化的调试工具、版本管理等等。</p>
<p>不难发现，VS Code 希望在编辑器和 IDE 之间找到一个平衡。在这样的设计思路下，打开编辑器，不需要创建任何的项目工程文件就可以开始使用，并高效便捷地操作文本；同时在编程语言插件的支持下能够得到语法检查、智能提示；还可以借助丰富的插件 API 拓展 VS Code 以满足自己的需求。</p>
<p>要达成这样的目标，难度可以说是非常大的，但 VS Code 取得了不错的成果。</p>
<h2 id="2-Visual-Studio？"><a href="#2-Visual-Studio？" class="headerlink" title="2. Visual Studio？"></a><font size=3>2. Visual Studio？</font></h2><p>Visual Studio（简称VS）是美国微软公司的开发工具包系列产品，是一个集成的开发环境，相对来说比较完整，它包括了整个软件生命周期中所需要的大部分工具，如代码完成工具、编译器、图形设计器、UML工具、代码管控工具、集成开发环境(IDE)等等，以简化开发人员构建应用程序的过程。通俗的讲，是一款编译器。</p>
<p>VS是微软面向Windows和MacOS的首选IDE，Visual Studio 出色的编辑和调试功能使其与竞争对手区分开来，Visual Studio 旨在成为用于构建应用程序的功能丰富、强大且全面的解决方案。</p>
<p>在Windows上，Visual Studio 目前支持17种工作负载，这些工作负载是针对不同开发目标的一致的工具和组件安装包。工作负载是对Visual Studio安装过程所作的重要改进，Visual Studio 的整个下载和安装很可能耗时数小时，会可能会塞满磁盘。</p>
<p>Visual Studio 2019有三种SKU：社区版(免费，不支持企业使用)，专业版(第一年1199美元&#x2F; 799美元续订)和企业版(第一年5999美元&#x2F;2569美元续订)。企业版拥有面向架构师的功能、高级调试和测试，这些功能是另两种SKU所没有的。</p>
<p>Visual Studio旨在成为世界上最好的IDE（集成开发环境），它提供完整的堆栈开发工具集，包括一个名为IntelliSense的强大代码完成组件，一个可以调试源代码和机器代码的调试器</p>
<h2 id="3-Visual-Studio-与-VSCode差异？"><a href="#3-Visual-Studio-与-VSCode差异？" class="headerlink" title="3. Visual Studio 与 VSCode差异？"></a><font size=3>3. Visual Studio 与 VSCode差异？</font></h2><table>
<thead>
<tr>
<th>Visual Studio</th>
<th>VS Code</th>
</tr>
</thead>
<tbody><tr>
<td>Visual Studio 是一种集成开发环境，也称为 IDE。</td>
<td>Visual Studio Code 是一个代码编辑器。 开发人员可以轻松地编辑他们的代码。</td>
</tr>
<tr>
<td>在跨不同平台执行时，VS 速度较慢。处理速度较慢。</td>
<td>VS Code 相对较快。</td>
</tr>
<tr>
<td>Visual Studio 有一个免费的编辑器供开发人员使用 但也提供了更好的付费 IDE 版本。</td>
<td>VS Code 完全免费并且是开源的。</td>
</tr>
<tr>
<td>VS 采用最好和最先进的 IntelliSense。</td>
<td>IntelliSense 在 VS Code 中相对不合格。</td>
</tr>
<tr>
<td>整体下载大小相当大。</td>
<td>与 Visual Studio 相比，Visual Studio Code 非常轻量级。 它不需要大量或大量下载。</td>
</tr>
<tr>
<td>VS 需要更多空间才能更好、更流畅地工作。</td>
<td>VS Code 相对来说不需要很多空间来运行。 它可以轻松地在 300 MB 的内存上运行。</td>
</tr>
<tr>
<td>Visual Studio 仅在 macOS 和 Windows 上运行。</td>
<td>VS Code 可以在 macOS、Windows 和 Linux 上运行。</td>
</tr>
<tr>
<td>没有多少专业开发的插件可用于 Visual Studio。</td>
<td>VS Code 附带了广泛的专业策划插件和扩展，生态丰富。 以满足各种编辑和编译需求。</td>
</tr>
</tbody></table>
<h2 id="4-VSCode安装"><a href="#4-VSCode安装" class="headerlink" title="4. VSCode安装"></a><font size=3>4. VSCode安装</font></h2><h3 id="1-VSCode下载"><a href="#1-VSCode下载" class="headerlink" title="1. VSCode下载"></a><font size=3>1. VSCode下载</font></h3><p>我们可以到VSCode的官网去：<a target="_blank" rel="noopener" href="https://code.visualstudio.com/">Visual Studio Code - Code Editing. Redefined</a></p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230427072908842.png" alt="image-20230427072908842" style="zoom: 25%;" />

<p>找到下载界面：<a target="_blank" rel="noopener" href="https://code.visualstudio.com/Download">Download Visual Studio Code - Mac, Linux, Windows</a></p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230427073034364.png" alt="image-20230427073034364" style="zoom:33%;" />

<p>我们会发现VSCode为我们提供了多种平台，多种安装方式，我们这里在windows下使用，所以选择windows版本的即可。</p>
<h3 id="2-VSCode安装"><a href="#2-VSCode安装" class="headerlink" title="2. VSCode安装"></a><font size=3>2. VSCode安装</font></h3><p>看我们下载的是哪一种包了，若是.zip的，那我们解压后直接运行即可，若是下载的Syatem Installer或者User Installer的，那下载后我们双击安装就可以啦，这里就不写过程了，VScode的安装还是很简单的，没什么坑。安装完毕后界面如下，这个不重要，因为这是我后边加了背景图的，第一次打开若是英文的话，可以安装中文插件，一般都有提示，后来好像直接内置到VSCode里边了，这不是本节笔记重点，就不详写了，可以多百度。</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230427073727984.png" alt="image-20230427073727984" style="zoom: 25%;" />

<h3 id="3-插件安装"><a href="#3-插件安装" class="headerlink" title="3. 插件安装"></a><font size=3>3. 插件安装</font></h3><p>VSCode为我们提供了很丰富的插件，常用的如下，还有一些插件后边需要了再安装，有一些可能已经是VSCode的内置功能了，如下面的多彩括号：</p>
<table>
    <tr>
        <td align="center" width=200px>插件名称</td>
        <td align="center">插件用途</td>
    </tr>
    <tr>
        <td align="left" width=200px>Bracket Pair Colorizer</td>
        <td align="left">多彩括号，不同层级的代码块的括号展现不同颜色(后来好像内置到VScode了)。</td>
    </tr>
    <tr>
        <td align="left" width=200px>Material Icon Theme</td>
        <td align="left">文件导航窗格不同文件图标样式。</td>
    </tr>
    <tr>
        <td align="left" width=200px>background-cover</td>
        <td align="left">设置VScode背景图片(需要对VScode有可执行权限，所以安装后可以找到安装目录，修改一下权限)。</td>
    </tr>
    <tr>
        <td align="left" width=200px>LinkerScript</td>
        <td align="left">GCC汇编链接文件语法高亮插件(后缀 .lds)。</td>
    </tr>
    <tr>
        <td align="left" width=200px>One Dark Pro</td>
        <td align="left">VScode编辑器主题插件。</td>
    </tr>
    <tr>
        <td align="left" width=200px>Arm Assembly</td>
        <td align="left">ARM GNU汇编语法高亮插件。</td>
    </tr>
    <tr>
        <td align="left" width=200px>Setting Sync</td>
        <td align="left">VScode配置文件同步插件。(有时候内置的有点不好用，这个时候就可以通过这个插件来实现同步，只是这个插件要跟Github一起使用)</td>
    </tr>
    <tr>
        <td align="left" width=200px>Remnote-SSH</td>
        <td align="left">远程连接服务器的SSH工具</td>
    </tr>
</table>


<p>另外还有一个插件，一般打开C语言源文件的时候都会提示安装，就是C&#x2F;C++扩展工具，我们找到这个 C&#x2F;C++ Extension Pack插件，安装即可，会自动安装另外两个。</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230427074055930.png" alt="image-20230427074055930" style="zoom: 50%;" />

<h2 id="5-打开工程文件夹"><a href="#5-打开工程文件夹" class="headerlink" title="5. 打开工程文件夹"></a><font size=3>5. 打开工程文件夹</font></h2><p>【文件】&rarr;【打开文件夹】</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230427165944750.png" alt="image-20230427165944750" style="zoom:33%;" />

<h2 id="6-配置VSCode"><a href="#6-配置VSCode" class="headerlink" title="6. 配置VSCode"></a><font size=3>6. 配置VSCode</font></h2><h3 id="6-1-报错示例"><a href="#6-1-报错示例" class="headerlink" title="6.1 报错示例"></a><font size=3>6.1 报错示例</font></h3><p>我们前边要是安装了C&#x2F;C++插件的话，它自带的语法检测会给我们报很多的错误，这些错误并不是语法错误，我们的工程没有任何问题的，只是VSCode中没有配置头文件路径以及没有设置 HAL 使用的相关宏定义，所以就会报。</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230427170146996.png" alt="image-20230427170146996" style="zoom:43%;" />

<h3 id="6-2-处理报错"><a href="#6-2-处理报错" class="headerlink" title="6.2 处理报错"></a><font size=3>6.2 处理报错</font></h3><h4 id="6-2-1-方式一：界面配置"><a href="#6-2-1-方式一：界面配置" class="headerlink" title="6.2.1 方式一：界面配置"></a><font size=3>6.2.1 方式一：界面配置</font></h4><ul>
<li>（1）打开UI界面配置：【Ctrl+Shift+p】&rarr;【输入C&#x2F;C++】&rarr;【C&#x2F;C++：编辑配置（UI）】</li>
</ul>
<p>我们在VSCode中按下Ctrl+Shift+p打开配置搜索栏，并输入 C&#x2F;C++ ：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230427171803285.png" alt="image-20230427171803285" style="zoom:48%;" />

<p>我们点击第二个，编辑配置（UI），然后会来到这样一个界面：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230427172022809.png" alt="image-20230427172022809" style="zoom: 25%;" />

<p>这就是C&#x2F;C++的配置界面。</p>
<ul>
<li>（2）配置包含路径：</li>
</ul>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230427172133345.png" alt="image-20230427172133345" style="zoom: 37%;" />

<p>这里就是配置包含路径的地方，要包含哪些路径？我们打开Makefile文件，找到以下部分：</p>
<figure class="highlight makefile"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># C includes</span></span><br><span class="line">C_INCLUDES =  \</span><br><span class="line">-ICore/Inc \</span><br><span class="line">-IDrivers/STM32F1xx_HAL_Driver/Inc \</span><br><span class="line">-IDrivers/STM32F1xx_HAL_Driver/Inc/Legacy \</span><br><span class="line">-IDrivers/CMSIS/Device/ST/STM32F1xx/Include \</span><br><span class="line">-IDrivers/CMSIS/Include</span><br></pre></td></tr></table></figure>

<p>这里就告诉我们头文件的目录啦，我们在上图的框中添加以下内容：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">Core/Inc</span><br><span class="line">Drivers/STM32F1xx_HAL_Driver/Inc</span><br><span class="line">Drivers/STM32F1xx_HAL_Driver/Inc/Legacy</span><br><span class="line">Drivers/CMSIS/Device/ST/STM32F1xx/Include</span><br><span class="line">Drivers/CMSIS/Include</span><br></pre></td></tr></table></figure>



<ul>
<li>（3）宏定义：</li>
</ul>
<p>接下来是配置全局的宏：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230427172444867.png" alt="image-20230427172444867" style="zoom:39%;" />

<p>这里我们怎么填呢？这就要去Makefile文件里寻找答案啦，我们打开Makefile文件，找到这一部分：</p>
<figure class="highlight makefile"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># C defines</span></span><br><span class="line">C_DEFS =  \</span><br><span class="line">-DUSE_HAL_DRIVER \</span><br><span class="line">-DSTM32F103xE</span><br></pre></td></tr></table></figure>

<p>这里就告诉了我们如何配置全局的宏定义，我们在上图VSCode C&#x2F;C++ UI配置的定义框中添加以下内容：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">USE_HAL_DRIVER</span><br><span class="line">STM32F103xE</span><br></pre></td></tr></table></figure>

<ul>
<li>（4）查看效果</li>
</ul>
<p>然后我们重新打开刚才的gpio.c文件，拉到相同的位置，会发现，已经没有报错啦：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230427173928801.png" alt="image-20230427173928801" style="zoom:46%;" />

<ul>
<li>（5）多了个文件夹？</li>
</ul>
<p>我们往旁边一看，就会发现，当我们编辑过 C&#x2F;C++：编辑配置（UI）界面后，在我们打开的文件夹目录下生成了一个.vscode目录，随之生成了一个名为 c_cpp_properties.json 的文件：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230427171510342.png" alt="image-20230427171510342" style="zoom:50%;" />

<p>文件内容如下：</p>
<figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br></pre></td><td class="code"><pre><span class="line"><span class="punctuation">&#123;</span></span><br><span class="line">    <span class="attr">&quot;configurations&quot;</span><span class="punctuation">:</span> <span class="punctuation">[</span></span><br><span class="line">        <span class="punctuation">&#123;</span></span><br><span class="line">            <span class="attr">&quot;name&quot;</span><span class="punctuation">:</span> <span class="string">&quot;Win32&quot;</span><span class="punctuation">,</span></span><br><span class="line">            <span class="attr">&quot;includePath&quot;</span><span class="punctuation">:</span> <span class="punctuation">[</span></span><br><span class="line">                <span class="string">&quot;$&#123;workspaceFolder&#125;/**&quot;</span><span class="punctuation">,</span></span><br><span class="line">                <span class="string">&quot;Core/Inc&quot;</span><span class="punctuation">,</span></span><br><span class="line">                <span class="string">&quot;Drivers/STM32F1xx_HAL_Driver/Inc&quot;</span><span class="punctuation">,</span></span><br><span class="line">                <span class="string">&quot;Drivers/STM32F1xx_HAL_Driver/Inc/Legacy&quot;</span><span class="punctuation">,</span></span><br><span class="line">                <span class="string">&quot;Drivers/CMSIS/Device/ST/STM32F1xx/Include&quot;</span><span class="punctuation">,</span></span><br><span class="line">                <span class="string">&quot;Drivers/CMSIS/Include&quot;</span></span><br><span class="line">            <span class="punctuation">]</span><span class="punctuation">,</span></span><br><span class="line">            <span class="attr">&quot;defines&quot;</span><span class="punctuation">:</span> <span class="punctuation">[</span></span><br><span class="line">                <span class="string">&quot;_DEBUG&quot;</span><span class="punctuation">,</span></span><br><span class="line">                <span class="string">&quot;UNICODE&quot;</span><span class="punctuation">,</span></span><br><span class="line">                <span class="string">&quot;_UNICODE&quot;</span><span class="punctuation">,</span></span><br><span class="line">                <span class="string">&quot;USE_HAL_DRIVER&quot;</span><span class="punctuation">,</span></span><br><span class="line">                <span class="string">&quot;STM32F103xE&quot;</span></span><br><span class="line">            <span class="punctuation">]</span><span class="punctuation">,</span></span><br><span class="line">            <span class="attr">&quot;compilerPath&quot;</span><span class="punctuation">:</span> <span class="string">&quot;C:\\LenovoSoft\\mingw64\\bin\\gcc.exe&quot;</span><span class="punctuation">,</span></span><br><span class="line">            <span class="attr">&quot;cStandard&quot;</span><span class="punctuation">:</span> <span class="string">&quot;c17&quot;</span><span class="punctuation">,</span></span><br><span class="line">            <span class="attr">&quot;cppStandard&quot;</span><span class="punctuation">:</span> <span class="string">&quot;gnu++17&quot;</span><span class="punctuation">,</span></span><br><span class="line">            <span class="attr">&quot;intelliSenseMode&quot;</span><span class="punctuation">:</span> <span class="string">&quot;windows-gcc-x64&quot;</span></span><br><span class="line">        <span class="punctuation">&#125;</span></span><br><span class="line">    <span class="punctuation">]</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;version&quot;</span><span class="punctuation">:</span> <span class="number">4</span></span><br><span class="line"><span class="punctuation">&#125;</span></span><br></pre></td></tr></table></figure>

<p>我们刚才配置的两个地方刚好就是includePath和defines。</p>
<h4 id="6-2-2-方式二：直接配置JSON文件"><a href="#6-2-2-方式二：直接配置JSON文件" class="headerlink" title="6.2.2 方式二：直接配置JSON文件"></a><font size=3>6.2.2 方式二：直接配置JSON文件</font></h4><p>我们在VSCode中按下Ctrl+Shift+p打开配置搜索栏，并输入 C&#x2F;C++ ：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230427171338781.png" alt="image-20230427171338781" style="zoom:50%;" />

<p>我们点击第一个，编辑配置（JSON），然后便会在当前目录下生成一个.vscode 目录，目录中会有一个名为 c_cpp_properties.json 的文件：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV16-STM32%E5%BC%80%E5%8F%91/LV16-07-%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7-01-STM32CubeMX-Makefile/img/image-20230427171510342.png" alt="image-20230427171510342" style="zoom:50%;" />

<p>我们打开这个文件，文件默认内容如下所示：</p>
<figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line"><span class="punctuation">&#123;</span></span><br><span class="line">    <span class="attr">&quot;configurations&quot;</span><span class="punctuation">:</span> <span class="punctuation">[</span></span><br><span class="line">        <span class="punctuation">&#123;</span></span><br><span class="line">            <span class="attr">&quot;name&quot;</span><span class="punctuation">:</span> <span class="string">&quot;Win32&quot;</span><span class="punctuation">,</span></span><br><span class="line">            <span class="attr">&quot;includePath&quot;</span><span class="punctuation">:</span> <span class="punctuation">[</span></span><br><span class="line">                <span class="string">&quot;$&#123;workspaceFolder&#125;/**&quot;</span></span><br><span class="line">            <span class="punctuation">]</span><span class="punctuation">,</span></span><br><span class="line">            <span class="attr">&quot;defines&quot;</span><span class="punctuation">:</span> <span class="punctuation">[</span></span><br><span class="line">                <span class="string">&quot;_DEBUG&quot;</span><span class="punctuation">,</span></span><br><span class="line">                <span class="string">&quot;UNICODE&quot;</span><span class="punctuation">,</span></span><br><span class="line">                <span class="string">&quot;_UNICODE&quot;</span></span><br><span class="line">            <span class="punctuation">]</span><span class="punctuation">,</span></span><br><span class="line">            <span class="attr">&quot;compilerPath&quot;</span><span class="punctuation">:</span> <span class="string">&quot;C:\\LenovoSoft\\mingw64\\bin\\gcc.exe&quot;</span><span class="punctuation">,</span></span><br><span class="line">            <span class="attr">&quot;cStandard&quot;</span><span class="punctuation">:</span> <span class="string">&quot;c17&quot;</span><span class="punctuation">,</span></span><br><span class="line">            <span class="attr">&quot;cppStandard&quot;</span><span class="punctuation">:</span> <span class="string">&quot;gnu++17&quot;</span><span class="punctuation">,</span></span><br><span class="line">            <span class="attr">&quot;intelliSenseMode&quot;</span><span class="punctuation">:</span> <span class="string">&quot;windows-gcc-x64&quot;</span></span><br><span class="line">        <span class="punctuation">&#125;</span></span><br><span class="line">    <span class="punctuation">]</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;version&quot;</span><span class="punctuation">:</span> <span class="number">4</span></span><br><span class="line"><span class="punctuation">&#125;</span></span><br></pre></td></tr></table></figure>

<p>我们直接修改成如下内容，可以达到一样的效果：</p>
<figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br></pre></td><td class="code"><pre><span class="line"><span class="punctuation">&#123;</span></span><br><span class="line">    <span class="attr">&quot;configurations&quot;</span><span class="punctuation">:</span> <span class="punctuation">[</span></span><br><span class="line">        <span class="punctuation">&#123;</span></span><br><span class="line">            <span class="attr">&quot;name&quot;</span><span class="punctuation">:</span> <span class="string">&quot;Win32&quot;</span><span class="punctuation">,</span></span><br><span class="line">            <span class="attr">&quot;includePath&quot;</span><span class="punctuation">:</span> <span class="punctuation">[</span></span><br><span class="line">                <span class="string">&quot;$&#123;workspaceFolder&#125;/**&quot;</span><span class="punctuation">,</span></span><br><span class="line">                <span class="string">&quot;Core/Inc&quot;</span><span class="punctuation">,</span></span><br><span class="line">                <span class="string">&quot;Drivers/STM32F1xx_HAL_Driver/Inc&quot;</span><span class="punctuation">,</span></span><br><span class="line">                <span class="string">&quot;Drivers/STM32F1xx_HAL_Driver/Inc/Legacy&quot;</span><span class="punctuation">,</span></span><br><span class="line">                <span class="string">&quot;Drivers/CMSIS/Device/ST/STM32F1xx/Include&quot;</span><span class="punctuation">,</span></span><br><span class="line">                <span class="string">&quot;Drivers/CMSIS/Include&quot;</span></span><br><span class="line">            <span class="punctuation">]</span><span class="punctuation">,</span></span><br><span class="line">            <span class="attr">&quot;defines&quot;</span><span class="punctuation">:</span> <span class="punctuation">[</span></span><br><span class="line">                <span class="string">&quot;_DEBUG&quot;</span><span class="punctuation">,</span></span><br><span class="line">                <span class="string">&quot;UNICODE&quot;</span><span class="punctuation">,</span></span><br><span class="line">                <span class="string">&quot;_UNICODE&quot;</span><span class="punctuation">,</span></span><br><span class="line">                <span class="string">&quot;USE_HAL_DRIVER&quot;</span><span class="punctuation">,</span></span><br><span class="line">                <span class="string">&quot;STM32F103xE&quot;</span></span><br><span class="line">            <span class="punctuation">]</span><span class="punctuation">,</span></span><br><span class="line">            <span class="attr">&quot;compilerPath&quot;</span><span class="punctuation">:</span> <span class="string">&quot;C:\\LenovoSoft\\mingw64\\bin\\gcc.exe&quot;</span><span class="punctuation">,</span></span><br><span class="line">            <span class="attr">&quot;cStandard&quot;</span><span class="punctuation">:</span> <span class="string">&quot;c17&quot;</span><span class="punctuation">,</span></span><br><span class="line">            <span class="attr">&quot;cppStandard&quot;</span><span class="punctuation">:</span> <span class="string">&quot;gnu++17&quot;</span><span class="punctuation">,</span></span><br><span class="line">            <span class="attr">&quot;intelliSenseMode&quot;</span><span class="punctuation">:</span> <span class="string">&quot;windows-gcc-x64&quot;</span></span><br><span class="line">        <span class="punctuation">&#125;</span></span><br><span class="line">    <span class="punctuation">]</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;version&quot;</span><span class="punctuation">:</span> <span class="number">4</span></span><br><span class="line"><span class="punctuation">&#125;</span></span><br></pre></td></tr></table></figure>

<h3 id="6-3-其他配置"><a href="#6-3-其他配置" class="headerlink" title="6.3 其他配置"></a><font size=3>6.3 其他配置</font></h3><p>这里我们配置的时候我就直接修改JSON文件了。</p>
<h4 id="6-3-1-compilerPath"><a href="#6-3-1-compilerPath" class="headerlink" title="6.3.1 compilerPath"></a><font size=3>6.3.1 compilerPath</font></h4><p>“compilerPath”这个标签必须指定，否则会出现程序中的基础依赖文件找不到或者宏控制异常，导致全部文件的基础数据类型（例如int8_t&#x2F;uint8_t等）找不到定义，如果只是简单地将编译器的依赖文件夹“include&#x2F;”路径添加到普通的工程头文件路径”includePath”下，仍然会出现问题（应该是编译器的自身控制宏导致的）。我们使用的是交叉编译工具链，这里就配置为我们使用的就行：</p>
<figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">&quot;compilerPath&quot;</span><span class="punctuation">:</span> <span class="string">&quot;C:\\Program Files (x86)\\Arm GNU Toolchain arm-none-eabi\\12.2 mpacbti-rel1\\bin\\arm-none-eabi-gcc.exe&quot;</span><span class="punctuation">,</span></span><br></pre></td></tr></table></figure>

<h4 id="6-3-2-intelliSenseMode"><a href="#6-3-2-intelliSenseMode" class="headerlink" title="6.3.2 intelliSenseMode"></a><font size=3>6.3.2 intelliSenseMode</font></h4><p>要使用的 IntelliSense 模式，该模式映射到 MSVC、gcc 或 Clang 的平台和体系结构变体。如果未设置或设置为 ${default}，则扩展将选择该平台的默认值。Windows 默认为 windows-msvc-x64，Linux 默认为 linux-gcc-x64，macOS 默认为 macos-clang-x64。我们可以选择特定 IntelliSense 模式以替代 ${default} 模式。这里一般就默认就好啦：</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="string">&quot;intelliSenseMode&quot;</span>: <span class="string">&quot;windows-msvc-x64&quot;</span>,</span><br></pre></td></tr></table></figure>

    </div>

    
    
    

    <footer class="post-footer">




    <div>
        
            <div style="text-align:center;color: #ccc;font-size:14px;">
            ----------本文结束
            <i class="fas fa-fan fa-spin" style="color: #FF1493; font-size: 1rem"></i>
            感谢您的阅读----------
            </div>
        
    </div>





  
  <div class="my_post_copyright"> 
    <p><span>文章标题:</span><a href="/post/daff314e.html">LV16-07-开发工具-01-STM32CubeMX-Makefile</a></p>
    <p><span>文章作者:</span><a href="/" title="欢迎访问 《苏木》 的学习笔记">苏木</a></p>
    <p><span>发布时间:</span>2023年06月04日 - 22:06</p>
    <p><span>最后更新:</span>2025年06月14日 - 00:25</p>
    <p><span>原始链接:</span><a href="/post/daff314e.html" title="LV16-07-开发工具-01-STM32CubeMX-Makefile">https://sumumm.github.io/post/daff314e.html</a></p>
    <p><span>许可协议:</span><i class="fab fa-creative-commons"></i> <a rel="license" href= "https://creativecommons.org/licenses/by-nc-nd/4.0/" target="_blank" title="Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)">署名-非商业性使用-禁止演绎 4.0 国际</a> 转载请保留原文链接及作者。</p>  
  </div>
  


          <div class="post-tags">
              <a href="/tags/LV16-STM32%E5%BC%80%E5%8F%91/" rel="tag"><i class="fa fa-tag"></i> LV16-STM32开发</a>
          </div>

        

          <div class="post-nav">
            <div class="post-nav-item">
                <a href="/post/eabbf614.html" rel="prev" title="LV16-07-开发工具-02-STM32CubeIDE">
                  <i class="fa fa-angle-left"></i> LV16-07-开发工具-02-STM32CubeIDE
                </a>
            </div>
            <div class="post-nav-item">
                <a href="/post/4329ee27.html" rel="next" title="LV16-06-MDK-03-SCT文件应用">
                  LV16-06-MDK-03-SCT文件应用 <i class="fa fa-angle-right"></i>
                </a>
            </div>
          </div>
    </footer>
  </article>
</div>






</div>
  </main>

  <footer class="footer">
    <div class="footer-inner">

  <div class="copyright">
    &copy; 2017 – 
    <span itemprop="copyrightYear">2025</span>
    <span class="with-love">
      <i class="fa fa-heart"></i>
    </span>
    <span class="author" itemprop="copyrightHolder">苏木</span>
  </div>
<div class="wordcount">
  <span class="post-meta-item">
    <span class="post-meta-item-icon">
      <i class="fa fa-chart-line"></i>
    </span>
      <span>站点总字数：</span>
    <span title="站点总字数">3.7m</span>
  </span>
  <span class="post-meta-item">
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
      <span>站点阅读时长 &asymp;</span>
    <span title="站点阅读时长">225:26</span>
  </span>
</div>




    <span id="sitetime"></span>
    <script defer language=javascript>
        function siteTime()
        {
            window.setTimeout("siteTime()", 1000);
            var seconds = 1000;
            var minutes = seconds * 60;
            var hours = minutes * 60;
            var days = hours * 24;
            var years = days * 365;
            var today = new Date();
            var todayYear = today.getFullYear();
            var todayMonth = today.getMonth()+1;
            var todayDate = today.getDate();
            var todayHour = today.getHours();
            var todayMinute = today.getMinutes();
            var todaySecond = today.getSeconds();
            /*==================================================
            Date.UTC() -- 返回date对象距世界标准时间(UTC)1970年1月1日午夜之间的毫秒数(时间戳)
            year        - 作为date对象的年份，为4位年份值
            month       - 0-11之间的整数，做为date对象的月份
            day         - 1-31之间的整数，做为date对象的天数
            hours       - 0(午夜24点)-23之间的整数，做为date对象的小时数
            minutes     - 0-59之间的整数，做为date对象的分钟数
            seconds     - 0-59之间的整数，做为date对象的秒数
            microseconds - 0-999之间的整数，做为date对象的毫秒数
            ==================================================*/
            var t1 = Date.UTC(2017, 
                              5, 
                              19, 
                              0, 
                              0, 
                              0); //北京时间
            var t2 = Date.UTC(todayYear,todayMonth,todayDate,todayHour,todayMinute,todaySecond);
            var diff = t2-t1;
            var diffYears = Math.floor(diff/years);
            var diffDays = Math.floor((diff/days)-diffYears*365);
            var diffHours = Math.floor((diff-(diffYears*365+diffDays)*days)/hours);
            var diffMinutes = Math.floor((diff-(diffYears*365+diffDays)*days-diffHours*hours)/minutes);
            var diffSeconds = Math.floor((diff-(diffYears*365+diffDays)*days-diffHours*hours-diffMinutes*minutes)/seconds);
            document.getElementById("sitetime").innerHTML="已在这里 "+diffYears+" 年 "+diffDays+" 天 "+diffHours+" 小时 "+diffMinutes+" 分钟 "+diffSeconds+" 秒";
        }
        siteTime();
    </script>



    </div>
  </footer>

  
  <div class="back-to-top" role="button" aria-label="返回顶部">
    <i class="fa fa-arrow-up fa-lg"></i>
    <span>0%</span>
  </div>
  <div class="reading-progress-bar"></div>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>


  
  <script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.1/anime.min.js" integrity="sha256-XL2inqUJaslATFnHdJOi9GfQ60on8Wx1C2H8DYiN1xY=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/next-theme-pjax/0.6.0/pjax.min.js" integrity="sha256-vxLn1tSKWD4dqbMRyv940UYw4sXgMtYcK6reefzZrao=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/fancyapps-ui/5.0.28/fancybox/fancybox.umd.js" integrity="sha256-ytMJGN3toR+a84u7g7NuHm91VIR06Q41kMWDr2pq7Zo=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/lozad.js/1.16.0/lozad.min.js" integrity="sha256-mOFREFhqmHeQbXpK2lp4nA3qooVgACfh88fpJftLBbc=" crossorigin="anonymous"></script>
<script src="/js/comments.js"></script><script src="/js/utils.js"></script><script src="/js/motion.js"></script><script src="/js/next-boot.js"></script><script src="/js/pjax.js"></script>

  <script src="https://cdnjs.cloudflare.com/ajax/libs/hexo-generator-searchdb/1.4.1/search.js" integrity="sha256-1kfA5uHPf65M5cphT2dvymhkuyHPQp5A53EGZOnOLmc=" crossorigin="anonymous"></script>
<script src="/js/third-party/search/local-search.js"></script>




  <script src="/js/third-party/fancybox.js"></script>

  <script src="/js/third-party/pace.js"></script>


  




  

  <script class="next-config" data-name="enableMath" type="application/json">true</script><script class="next-config" data-name="mathjax" type="application/json">{"enable":true,"tags":"none","js":{"url":"https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.2/es5/tex-mml-chtml.js","integrity":"sha256-MASABpB4tYktI2Oitl4t+78w/lyA+D7b/s9GEP0JOGI="}}</script>
<script src="/js/third-party/math/mathjax.js"></script>


 
        <div id="click-show-text"
            data-mobile = false
            data-text = 富强,民主,文明,和谐,自由,平等,公正,法制,爱国,敬业,诚信,友善
            data-fontsize = 15px
            data-random= false>
        </div>
       

      
        <script async src=https://cdn.jsdelivr.net/npm/hexo-next-mouse-effect@latest/click/showText.js></script>
      

      
    




    <script async src="/js/fancybox_param.js"></script>





<!-- APlayer本体 -->



</body>
</html>
